package org.example.route.mapper;

import org.apache.ibatis.annotations.*;
import org.example.route.model.dto.TrainChangeStatusDTO;
import org.example.route.model.dto.TrainQueryDTO;
import org.example.route.model.pojo.Train;

import java.util.List;

@Mapper
public interface TrainMapper {


    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into train (serial_number,status,kind) values (#{serialNumber},#{status},#{kind})")
    void add(Train train);

    List<Train> list(TrainQueryDTO trainQueryDTO);

    @Select("select serial_number from train where id = #{trainId}")
    String getSerialById(Long trainId);

    @Update("update train set status = #{status} where id = #{id}")
    void changeStatus(TrainChangeStatusDTO trainChangeStatusDTO);

    @Select("select kind from train where id = #{trainId}")
    Long getKindById(Long trainId);


    @Delete("delete from train where id = #{id}")
    void delete(Long id);

    /**修改列车**/
    void update(Train train);

    @Select("select * from train where id = #{trainId}")
    Train getById(Long trainId);
}
